//
//  HSMyView.swift
//  HomeSchoolDemo
//
//  Created by rimi on 2016/10/13.
//  Copyright © 2016年 黄华强. All rights reserved.
//

import UIKit

class HSMyView: UIView {

    
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    
    var bgColor: UIColor = #colorLiteral(red: 0.1764705926, green: 0.4980392158, blue: 0.7568627596, alpha: 1)
    var bgTitle: String = ""
    
    override func draw(_ rect: CGRect) {
        // Drawing code
        let ctx = UIGraphicsGetCurrentContext()
        ctx?.saveGState()
        ctx?.move(to: CGPoint(x: 0, y: 0))
        ctx?.addLine(to: CGPoint(x: 28, y: 0))
        ctx?.addLine(to: CGPoint(x: 28, y: 30))
        ctx?.addLine(to: CGPoint(x: 14, y: 22))
        ctx?.addLine(to: CGPoint(x: 0, y: 30))
        
        ctx?.closePath()
        bgColor.setFill()

        ctx?.drawPath(using: .fillStroke)
        
        (bgTitle as NSString).draw(in: CGRect(x: 3, y: 5, width: 28, height: 20), withAttributes: [NSFontAttributeName:UIFont.systemFont(ofSize: 11),NSForegroundColorAttributeName:#colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)])
    
    }
 
     init(frame: CGRect,title: String,color:UIColor) {
        super.init(frame: frame)
        
        bgTitle = title
        bgColor = color
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    

}
